<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .box{width:10px;height:10px;background: red;position: absolute;left:0;top:0;display:none;}
    </style>
</head>
<body>
    
</body>
<script>

    // 创建元素，设置样式，插入页面
    var div = document.createElement("div");
    document.body.appendChild(div);
    div.className = "box";

    // 页面的移动事件
    document.onmousemove = function(eve){
        // 获取事件对象
        var e = eve || window.event;

        // 显示元素
        div.style.display = "block";

        // 元素跟随鼠标移动
        div.style.left = e.pageX + 10 + "px";
        div.style.top = e.pageY + 10 + "px";

    }



</script>
</html>